//Created by: Huiyi

Ext.define('MajorProjectSenchaTouch.view.Announcements.AnnouncementsListItem', {
    extend: 'Ext.dataview.component.DataItem',
    xtype : 'announcementsListItem',
    alias: 'widget.announcementsPage',
    requires:[
    'Ext.Label',
    'Ext.Panel'
    ],
    config: {
        
        date:{
            cls:'date'
        },
        announcements:{
            cls:'announcements'
        },
        
      
        //--------------------------------------------------------------------------------------------------------------
        dataMap: {            
            getDate: {
                setHtml: 'date'
            },
            getAnnouncements:{
                setHtml: 'announcements'
            }
        }
    },
    
    //apply methods----------------------------------------------------------------------------------
    
	
	applyDate:function(config){
        return Ext.factory(config, Ext.Label, this.getDate());
    },
	
	updateDate: function(newDate, oldDate) {

        if (newDate) {
            this.add(newDate);
        }

        if (oldDate) {
            this.remove(oldDate);
        }
    },
	
	applyAnnouncements:function(config){
        return Ext.factory(config, Ext.Panel, this.getAnnouncements());
    },
	
	updateAnnouncements: function(newAnnouncements, oldAnnouncements) {
        if (newAnnouncements) {
            this.add(newAnnouncements);
        }

        if (oldAnnouncements) {
            this.remove(oldAnnouncements);
        }
    }
	
});
